﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FMSpaceShooter.Screens;
using Microsoft.Xna.Framework;

namespace FMSpaceShooter.GameObjects.EnemyFolder
{
    class EnemyShell :EnemyBase
    {
        public override int Points { get { return 0; } }
        public new const string TypeName = "EnemyShell";
        public const string imageName = "Images/Enemies/EnemyShell";
        private double timeLaunched;
        private Vector2 direction;
        private EnemyBase boss;
        

        public EnemyShell(GameplayScreen screen, Vector2 position, float rotation, EnemyBase parent)
            :base(screen, imageName, position, 3000)
        {
            timeLaunched = 0;
            direction= new Vector2((float)Math.Sin(rotation),(float)-Math.Cos(rotation));
            direction.Normalize();
            direction *= 4;
            boss = parent; ;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (timeLaunched > 1)
            {
                position += (direction * (float)(gameTime.ElapsedGameTime.TotalSeconds * 100));
            }
            else
            {
                position = boss.Position;
            }
            rotation += Util.Tools.VectorToAngle(direction);
            timeLaunched += gameTime.ElapsedGameTime.TotalSeconds;
            if (timeLaunched > 2)
            {
               this.Die();
               screen.GOM.AddToPlay(new OrbitalEnemy(screen,position));
            }

        }

        public override void Die()
        {
            screen.GOM.DisposeOf(this);
        }

    }
}
